#include<bits/stdc++.h>
using namespace std;
const int N=305;
int n,mod,ans,f[N][N];
inline int Inv(int x){
	int ans=1;
	for(int y=mod-2;y;y>>=1,x=1ll*x*x%mod)
		if(y&1) ans=1ll*ans*x%mod;
	return ans;
}
int fac[N],ifac[N],w[N][N];
inline void init(const int M){
	for(int i=1;i<=n;++i){
		w[i][0]=1;
		for(int j=1;j<=n;++j) w[i][j]=1ll*w[i][j-1]*i%mod;
	}
	fac[0]=ifac[0]=1;
	for(int i=1;i<=M;++i) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[M]=Inv(fac[M]);
	for(int i=M-1;i;--i) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
inline void Mod(int &x){return (x>=mod)&&(x-=mod),void();}
inline int C(int n,int m){return 1ll*fac[n]*ifac[n-m]%mod*ifac[m]%mod;}
inline int A(int n,int m){return 1ll*fac[n]*ifac[n-m]%mod;}
int F(int i,int j){
	if(!i) return 1;
	if(~f[i][j]) return f[i][j];
	f[i][j]=0;
	for(int k=1;k<=i;++k) Mod(f[i][j]+=1ll*F(i-k,k)*w[j][k]%mod*C(i,k)%mod);
	return f[i][j];
}
int main(){
	freopen("tree.in","r",stdin);
	freopen("tree.out","w",stdout);
	scanf("%d%d",&n,&mod);
	init(n);
	memset(f,-1,sizeof(f));
	for(int i=1;i<=n;++i){
	
		Mod(ans+=1ll*F(n-i,i)*A(n,i)%mod*w[2][n-i]%mod);
	}
	printf("%d\n",ans);
	return 0;
}

